package cn.sibu.plugin.authorize.util;

 
import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUitls {

	public static String SP_NAME = "config_home_0x11";
	private static SharedPreferences sp;

	/**
	 * 
	 * @param key 键
	 * @param value 值
	 */
	public static void saveString(Context context, String key, String value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putString(key, value).commit();
	}

	/**
	 * 
	 * @param context
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static String getString(Context context, String key, String defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getString(key, defValue);
	}

	/**
	 * 
	 * @param context
	 * @param key
	 * @param value
	 */
	public static void saveInt(Context context, String key, int value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putInt(key, value).commit();
	}

	/**
	 * 
	 * @param context
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static int getInt(Context context, String key, int defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getInt(key, defValue);
	}
	/**
	 * 
	 * TODO 保存长整形数据
	 * @param @param context
	 * @param @param key
	 * @param @param value
	 * @throw 
	 * @return void
	 */
	
	public static void saveLong(Context context ,String key,long value){
		if(sp==null){
			sp = context.getSharedPreferences(SP_NAME, 0);
		}
	  sp.edit().putLong(key, value).commit();
	}
	/**
	 * 
	 * TODO<取长整形数据> 
	 * @param @param context
	 * @param @param key
	 * @param @param defValue
	 * @param @return
	 * @throw 
	 * @return long
	 */
	public static long getLong(Context context, String key, long defValue){
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getLong(key, defValue);
	}
	
	
	
}
